#!/usr/bin/env python
#####
#
# Dummy UDP Server
# Shoufu Luo 
#
######


import socket,sys
import SocketServer
import threading

if len(sys.argv) != 3:
	print "Usage: %s <ip> <port>" % sys.argv[0]
	sys.exit(1)

ip=sys.argv[1]
port=int(sys.argv[2])

class udp_server(SocketServer.BaseRequestHandler):
	def handle(self):
		data = self.request[0].strip()
		sock = self.request[1]
		print "%s:%s" % (self.client_address[0], data)
		sock.sendto(data.upper(), self.client_address)

if __name__ == "__main__":
	server = SocketServer.UDPServer((ip, port), udp_server)
	print "Server: listening on %d ..." % port
	server.serve_forever()

	print "We quit!"
